# the minimum version of CMake.
cmake_minimum_required(VERSION 3.5.0)
project(turbotransjson)

SET(CMAKE_CXX_STANDARD 17)
add_compile_options(-D_FORTIFY_SOURCE=2)
set(YYJSON_DISABLE_UTF8_VALIDATION ON)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -DNDEBUG -flto")
set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(PROJECT_ROOT_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../../")

if(DEFINED PACKAGE_FIND_FILE)
    include(${PACKAGE_FIND_FILE})
endif()

include_directories(${NATIVERENDER_ROOT_PATH}
                    ${NATIVERENDER_ROOT_PATH}/include
                    ${PROJECT_ROOT_PATH}/third_party/libboundscheck/include
                    ${PROJECT_ROOT_PATH}/third_party/yyjson/src)

file(GLOB_RECURSE SOURCE_FILES
    "${NATIVERENDER_ROOT_PATH}/napi_init.cpp"
    "${NATIVERENDER_ROOT_PATH}/src/*.cpp"
    "${PROJECT_ROOT_PATH}/third_party/yyjson/src/yyjson.c"
    "${PROJECT_ROOT_PATH}/third_party/libboundscheck/src/*.c"
)

add_definitions("-DLOG_TAG=\"testTag\"")

add_library(turbotransjson SHARED ${SOURCE_FILES})
target_link_libraries(turbotransjson PUBLIC libace_napi.z.so libhilog_ndk.z.so)
